---
layout: m1x_soap
title: Assign Product
---


<h2><a name="catalog_category.assignProduct-Module%3AMageCatalog"></a>Module: Mage_Catalog</h2>

<p>The Mage_Catalog module allows you to manage categories and products.</p>

<h4><a name="catalog_category.assignProduct-ResourceName%3Acatalogcategory"></a>Resource Name: catalog_category</h4>

<p><b>Aliases:</b></p>
<ul>
	<li>category</li>
</ul>


<h5><a name="catalog_category.assignProduct-Method%3A"></a>Method:</h5>

<ul>
	<li>catalog_category.assignProduct (SOAP V1)</li>
	<li>catalogCategoryAssignProduct (SOAP V2)</li>
</ul>


<p>Assign a product to the required category.</p>

<p><b>Aliases:</b></p>
<ul>
	<li>category.assignProduct</li>
</ul>



<p><b>Arguments:</b></p>

<table><tbody>
<tr>
<th> Type </th>
<th> Name </th>
<th> Description </th>
</tr>
<tr>
<td> string </td>
<td> sessionId </td>
<td> Session ID </td>
</tr>
<tr>
<td> int </td>
<td> categoryId </td>
<td> ID of the category </td>
</tr>
<tr>
<td> string </td>
<td> product/productId </td>
<td> ID or SKU of the product to be assigned to the category </td>
</tr>
<tr>
<td> string </td>
<td> position </td>
<td> Position of the assigned product in the category (optional) </td>
</tr>
<tr>
<td> string </td>
<td> identifierType </td>
<td> Defines whether the product ID or SKU is passed in the 'product' argument </td>
</tr>
</tbody></table>



<p><b>Returns</b>:</p>

<table><tbody>
<tr>
<th> Type </th>
<th> Description </th>
</tr>
<tr>
<td> boolean </td>
<td> True if the product is assigned to the specified category </td>
</tr>
</tbody></table>


<h4><a name="catalog_category.assignProduct-Examples"></a>Examples</h4>

<h5><a name="catalog_category.assignProduct-RequestExampleSOAPV1"></a>Request Example SOAP V1</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<div>
		<pre class="theme: Default; brush: php; gutter: false">$client = new SoapClient('http://magentohost/api/soap/?wsdl');

// If somestuff requires API authentication,
// then get a session token
$session = $client-&gt;login('apiUser', 'apiKey');

$result = $client-&gt;call($session, 'catalog_category.assignProduct', array('categoryId' =&gt; '4', 'product' =&gt; '1'));
var_dump($result);

// If you don't need the session anymore
//$client-&gt;endSession($session);</pre>
		</div>
</div></div>


<h5><a name="catalog_category.assignProduct-RequestExampleSOAPV2"></a>Request Example SOAP V2</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<div>
		<pre class="theme: Default; brush: php; gutter: false">$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); // TODO : change url
$sessionId = $proxy-&gt;login('apiUser', 'apiKey'); // TODO : change login and pwd if necessary

$result = $proxy-&gt;catalogCategoryAssignProduct($sessionId, '4', '3');
var_dump($result);</pre>
		</div>
</div></div>

<h5><a name="catalog_category.assignProduct-RequestExampleSOAPV2%28WSIComplianceMode%29"></a>Request Example SOAP V2 (WS-I Compliance Mode)</h5>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<div>
		<pre class="theme: Default; brush: php; gutter: false">$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

$sessionId = $proxy-&gt;login((object)array('username' =&gt; 'apiUser', 'apiKey' =&gt; 'apiKey'));

$result = $proxy-&gt;catalogCategoryAssignProduct((object)array('sessionId' =&gt; $sessionId-&gt;result, 'categoryId' =&gt; '5', 'productId' =&gt; '1', 'position' =&gt; '5'));
var_dump($result-&gt;result);</pre>
		</div>
</div></div>


